/**
 * ****************************************************************************
 * Project: RoboBridge
 * ----------------------------------------------------------------------------
 * -------------------------- [c]2012 - KrawallMann ---------------------------
 * ---------------------- http://www.krawallmann.de.tc/ -----------------------
 * ****************************************************************************
 * File: CommandType.java Package: tc.de.krawallmann.robobridge.communication
 * Version: 1.0 Author(s): KrawallMann
 * ****************************************************************************
 * Description:
 * ****************************************************************************
 */
package tc.de.krawallmann.robobridge.communication;

/**
 * The Enum CommandType contains the used command types.
 * 
 * @author KrawallMann
 * @version 1.0
 */
public enum CommandType {

	/** The ack. */
	ACK(1),
	/** The heartbeat. */
	HEARTBEAT(2),
	/** The hello. */
	HELLO(3),
	/** The login. */
	LOGIN(255),
	/** The ping. */
	PING(4),
	/** The sensor update interval. */
	SENSOR_UPDATE_INTERVAL(8),
	/** The update device data. */
	UPDATE_DEVICE_DATA(5),
	/** The update robot device. */
	UPDATE_ROBOT_DEVICE(6);

	/**
	 * Gets the.
	 * 
	 * @param commandId
	 *            the command id
	 * @return the command type
	 */
	public static CommandType get(final int commandId) {
		for (final CommandType t : CommandType.values()) {
			if (t.commandId == commandId) {
				return t;
			}
		}
		throw new IllegalArgumentException("Command id " + commandId + " is not supported!");
	}

	/** The command id. */
	private int commandId;

	/**
	 * Instantiates a new command type.
	 * 
	 * @param commandId
	 *            the command id
	 */
	private CommandType(final int commandId) {
		this.commandId = commandId;
	}

	/**
	 * Gets the command id.
	 * 
	 * @return the command id
	 */
	public int getCommandId() {
		return commandId;
	}

}
